﻿using CommonServiceLocator.NinjectAdapter;
using Microsoft.Practices.ServiceLocation;
using Ninject.Modules;
using Subfaculty.Common.Entities;
using Subfaculty.Common.Interfaces;
using Subfaculty.Common.Interfaces.Services;
using Subfaculty.Infrastructure.Repositories;

namespace Subfaculty.WebApplication
{
	public class SubfacultyModule : NinjectModule
	{
		public override void Load()
		{
			var kernel = new Ninject.StandardKernel();
			var locator = new NinjectServiceLocator(kernel);

			kernel.Bind<ISessionProvider>().To<SessionProvider>().InSingletonScope();
			kernel.Bind<IDisciplineRepository>().To<DisciplineRepository>().InSingletonScope();
			kernel.Bind<IDepartmentRepository>().To<DepartmentRepository>().InSingletonScope();
			kernel.Bind<IStudyAreaRepository>().To<StudyAreaRepository>().InSingletonScope();
			kernel.Bind<IStudyYearRepository>().To<StudyYearRepository>().InSingletonScope();
			kernel.Bind<IStudyGroupRepository>().To<StudyGroupRepository>().InSingletonScope();
			ServiceLocator.SetLocatorProvider(() => locator);
		}
	}
}